package net.proef.commons.lang.builder;

import org.apache.commons.lang.builder.StandardToStringStyle;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * <p>
 * Controls <code>String</code> formatting for {@link ToStringBuilder}. The main
 * public interface is always via <code>ToStringBuilder</code>.
 * </p>
 * 
 * <p>
 * These classes are intended to be used as <code>Singletons</code>. There is no
 * need to instantiate a new style each time. A program will generally use one
 * of the predefined constants on this class. Alternatively, the
 * {@link StandardToStringStyle} class can be used to set the individual
 * settings. Thus most styles can be achieved without subclassing.
 * </p>
 * 
 * @author Sander Smeman
 * @since 0.1
 */
public final class ExtendedToStringStyle extends ToStringStyle {

	/**
	 * The short prefix <em>and</em> no field names toString style is a
	 * combination of {@link ToStringStyle#SHORT_PREFIX_STYLE} and
	 * {@link ToStringStyle#NO_FIELD_NAMES_STYLE}. Using the Using the
	 * <code>Person</code>example from {@link ToStringBuilder}, the output would
	 * look like this:
	 * 
	 * <pre>
	 * Person[John Doe,33,false]
	 * </pre>
	 */
	public static final ToStringStyle SHORT_PREFIX_NO_FIELD_NAMES_STYLE = new ShortPrefixNoFieldNameToStringStyle();

	private static final long serialVersionUID = 1L;

	private static final class ShortPrefixNoFieldNameToStringStyle extends
			ToStringStyle {
		private static final long serialVersionUID = 1L;

		public ShortPrefixNoFieldNameToStringStyle() {
			super();
			// from NoFieldNameToStringStyle
			this.setUseFieldNames(false);

			// from ShortPrefixToStringStyle
			this.setUseShortClassName(true);
			this.setUseIdentityHashCode(false);
		}

		private Object readResolve() {
			return ExtendedToStringStyle.SHORT_PREFIX_NO_FIELD_NAMES_STYLE;
		}
	}
}
